<?php

/*
 * Treasure worth $1
 * 
 * When you play this, you may gain a Copper, putting it into your hand.
 * 
 * When you gain this, each other player gains a Curse.
 * 
 * TODO: test with play all treasures
 */

class IllGottenGains extends Card implements iKingdom, iHinterlands, iTreasure {
    
    public function __construct() {
        parent::__construct("Ill-Gotten Gains", 5);
        $this->value = new Price(1);
    }
    
    public function getDescription() {
        return array(
            "Worth $1.",
            "When you play this, you may gain a Copper, putting it into your hand.",
            "When you gain this, each other player gains a Curse.");
    }
    
        public function getDisplayName($quantity = 1) {
        if ($quantity == 1) {
            return "Ill-Gotten Gains";
        }
        return $quantity . " Ill-Gotten Gains";
    }
    
    public function autoPlayNum(Game $game) {
        return -1;
    }
    
    public function play(Game $game, $isRealCard) {
        $options = array(new Option(1, "Yes"), new Option(2, "No"));
        $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "Gain a copper?");
        $answer = $output[0];
        if ($answer == "Yes") {
            $copper = $game->moveCardFromPileToPile("Copper", BoardCards, PlayHand);
            ScreenDisplay::addScreenMessage($game, true, "gain " . nicePrint($copper), " gains " . ScreenDisplay::$LMSG);
        }
        $game->cardPaymentFinished();
        return true;
    }
    
    public function gainThisCard(Game $game, $name = null){
        $others = $game->getOtherPlayersNames(false, $name);
        foreach ($others as $other) {
            $curse = $game->moveCardFromPileToPile("Curse", BoardCards, DiscardPile, $other);
            ScreenDisplay::addScreenMessage($game, true, "gain " . nicePrint($curse), "gains " . ScreenDisplay::$LMSG, $other);
        }
        
        $game->setTempCard($this);
        return true;
    }
    
}
?>
